package com.cn.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.cn.bean.Provider;
import com.cn.bean.Servicecatalog;
import com.cn.dao.ServicecatalogDAO;
import com.cn.entity.ServicecatalogEntity;
import com.cn.service.ServicecatalogService;
import com.opensymphony.xwork2.ActionContext;

public class ServicecatalogServiceImpl implements ServicecatalogService{
	private ServicecatalogDAO servicecatalogDao = null;
	HttpServletRequest request;
	
	public ServicecatalogDAO getServicecatalogDao() {
		return servicecatalogDao;
	}

	public void setServicecatalogDao(ServicecatalogDAO servicecatalogDao) {
		this.servicecatalogDao = servicecatalogDao;
	}

	/**
	 * 通过ST的name查找SC
	 */
	public List getSCbyST()throws Exception{
		request = ServletActionContext.getRequest();
		request.setCharacterEncoding("utf-8");
		String st_name = request.getParameter("st_name");
		List list=servicecatalogDao.getSCbyST(st_name);
		List<ServicecatalogEntity> list1=new ArrayList<ServicecatalogEntity>();
		for(int i=0;i<list.size();i++){
			Servicecatalog sc=(Servicecatalog) list.get(i);
			ServicecatalogEntity se=new ServicecatalogEntity(sc.getId(),sc.getName(),sc.getPrice());
			list1.add(se);
		}
		return list1;
		
	}
	public List listAllCatalog(int id)
	{
		return servicecatalogDao.listAllCatalog(id);
	}
	
	public boolean deleteProviderCatalog(int pro_id,int sc_id)
	{
		return servicecatalogDao.deleteProviderCatalog(pro_id,sc_id);
	}
	
	public boolean changeProviderCatalog(int pro_id,int sc_id,float price)
	{
		return servicecatalogDao.changeProviderCatalog(pro_id,sc_id,price);
	}


	public void catalogPrice() {
		servicecatalogDao.catalogPrice();
	}	
	
}
